﻿@model IEnumerable<LIMIS.Models.UserProfile>
@{
    ViewBag.Title = "用户管理";
    var roles = ((string[])ViewBag.Roles).OrderBy(x => x);
}

<table>
    <tr>
        <th>用户名</th>
        <th>角色</th>
        <th>操作</th>
    </tr>

    @foreach (var user in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => user.UserName)
            </td>
            <td>
                @foreach (var role in roles)
                {
                        using (Html.BeginForm("UserToRole", "Account"))
                        {
                            <input type="hidden" value="@user.UserName" name="username" />
                            <input type="hidden" value="@role" name="rolename" />
                            <input type="radio" name="ischecked" onclick="this.form.submit();" value="true" checked="@System.Web.Security.Roles.IsUserInRole(@user.UserName, role)" />
                            
                        }
                }
            </td>
            <td>
                @Html.ActionLink("修改", "Edit", new { id = user.UserId }) |
            @Html.ActionLink("密码重置", "Reset", new { id = user.UserId }) |
            @Html.ActionLink("删除", "Delete", new { id = user.UserId })
            </td>
        </tr>
    }

</table>
